#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ff first
#define ss second
#define int long long
#define pb push_back
#define in insert
//#define mp make_pair
#define len(s) (int)s.size()
#define pii pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define pqb priority_queue<int>
#define pqs priority_queue<int,vi,greater<int> >
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
// #define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type) type *arr=new type[n];
#define w(x) int x; cin>>x; while(x--)
#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key
/*
//when using map with pair<int, int> as key
struct hash_pair {
template <class T1, class T2>
size_t operator()(const pair<T1, T2>& p) const
{
auto hash1 = hash<T1>{}(p.first);
auto hash2 = hash<T2>{}(p.second);
if (hash1 != hash2) {
return hash1 ^ hash2;
}
// If hash1 == hash2, their XOR is zero.
return hash1;
}
};
*/
// int power(int x, int y){
// int res = 1;
// x = x % mod;
// if (x == 0)
// return 0;
// while (y > 0){
// if (y & 1)
// res = (res*1LL*x) % mod;
// y = y>>1;
// x = (x*1LL*x) % mod;
// }
// return res;
// }
// int multiply(int a, int b){
// int res = 0;
// a %= mod;
// while(b){
// if(b & 1)
// res = (res+ a)%mod;
// a= (2* 1LL* a) % mod;
// b>>= 1;
// }
// return res;
// }
/*
void primeFactors(int n, unordered_map<int, int>& mp){
while(n%2== 0){
mp[2]++;
n = n/2;
}
for(int i= 3; i*i<= n; i+= 2){
while(n%i== 0){
mp[i]++;
n = n/i;
}
}
if(n> 2)
mp[n]++;
}
*/
// int store[200001];
// int fac(int n){
// if(store[n]!= -1)
// return store[n];
// if(n== 1 || n== 0)
// return store[n]= 1;
// return store[n]= (n* 1LL* fac(n-1))%mod;
// }
//SIEVE OF ERATOSTHENES
// const int N= 1e6+ 6;
// vector<int> isprime(N, 1);
// vector<int> sprime;
// void sieve(int n){
// isprime[0]= isprime[1]= 0;
// for(int i= 2; i<= n; ++i){
// if(!isprime[i])
// continue;
// sprime.pb(i);
// for(int j= i*i; j<= n; j+= i)
// isprime[j]= 0;
// }
// }
void solve(){
int x,y; cin>>x>>y;
if(x> y)
cout<<x+y<<endl;
else{
cout<<y- y%x/2<<endl;
}
}
int32_t main()
{
fast_io;
int t; cin>>t;
while(t--){
solve();
}
return 0;
}
237A - Free Cash | 1615B - And It's Non-Zero |
1619E - MEX and Increments | 34B - Sale |
1436A - Reorder | 1363C - Game On Leaves |
1373C - Pluses and Minuses | 1173B - Nauuo and Chess |
318B - Strings of Power | 1625A - Ancient Civilization |
864A - Fair Game | 1663B - Mike's Sequence |
448A - Rewards | 1622A - Construct a Rectangle |
1620A - Equal or Not Equal | 1517A - Sum of 2050 |
620A - Professor GukiZ's Robot | 1342A - Road To Zero |
1520A - Do Not Be Distracted | 352A - Jeff and Digits |
1327A - Sum of Odd Integers | 1276A - As Simple as One and Two |
812C - Sagheer and Nubian Market | 272A - Dima and Friends |
1352C - K-th Not Divisible by n | 545C - Woodcutters |
1528B - Kavi on Pairing Duty | 339B - Xenia and Ringroad |
189A - Cut Ribbon | 1182A - Filling Shapes |